﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace CardGenerator.ViewModel;

public class IsNullConverter : IValueConverter
{
    public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if ((parameter as Boolean?) ?? false)
        {
            return (value is null); 
        }
        return !(value is null);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

public class CardTemplateToStringConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return (value as CardTemplate)?.Name ?? "Error to convert";
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}